var com_up = {};

com_up.userid = null;
com_up.companyId = null;

com_up.ids = ['company_name', 'company_city', 'company_person', 'company_cell', 'company_type', 'company_desc'];

com_up.getData = function() {
    var req = new common.Request();
    var url = "company/companyInfo.action";
    var reqData = {};
    var urlParm = common.GetParameters();
    reqData['userId'] = urlParm['userid'];
    com_up.userid = reqData['userId'];
    req.sendMethodRequest("get", url , reqData, function(e){
    	if (e != null) {
    		if (e != null && e.companyInfo != null) {
    			com_up.companyId = e.companyInfo.companyId;
        		$('#company_name').val(e.companyInfo.companyName);
            	$('#company_city').val(e.companyInfo.companyCity);
            	$('#company_person').val(e.companyInfo.linkMan);
            	$('#company_cell').val(e.companyInfo.companyMoble);
            	$('#company_type').val(e.companyInfo.business);
            	$('#company_desc').val(e.companyInfo.companyProfile);
        	}
    	}
    },function(e){
    	
    });
}

com_up.submit = function() {
	$('#update_button').click(function(){
		var req = new common.Request();
		var reqData = {};
		reqData['companyId'] = com_up.companyId;
		reqData['companyName'] = $('#company_name').val();
		reqData['companyCity'] = $('#company_city').val();
		reqData['linkMan'] = $('#company_person').val();
		reqData['companyMoble'] = $('#company_cell').val();
		reqData['business'] = $('#company_type').val();
		reqData['companyProfile'] = $('#company_desc').val();
		var url = "company/updateCompanyInfo.action";
		req.sendRequest(url, reqData, function(e){
			console.log(e);
			if (e != null && e.isSuccess == true) {
				window.location = "company_info.html?userid=" + com_up.userid;
			}
		}, function(){
			
		});
	});
}

com_up.getHeight = function () {
    var height = $(document).height();
    window.parent.index.iframeResize(height);
}

com_up.init = function() {
	com_up.getHeight();
	com_up.getData();
	com_up.submit();
}

$(document).ready(function() {
	com_up.init();
});



